package com.example.myapplication;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import java.util.zip.Inflater;

public class FragmentMenu extends Fragment {
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view= inflater.inflate(R.layout.leftlayout,container,false);
        Button btnlyx=view.findViewById(R.id.lyx);
        btnlyx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //首先找到MAINACTIVITY
                MainActivity mainActivity=(MainActivity) getActivity();

                FragmentManager fm=mainActivity.getSupportFragmentManager();
                Fragment fragment=fm.findFragmentById(R.id.fragmentRight);
                View v=fragment.getView();
                TextView tv=v.findViewById(R.id.text);
                tv.setText("李宇轩");
            }
        });
        Button btnycx=view.findViewById(R.id.ycx);
        btnycx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //首先找到MAINACTIVITY
                MainActivity mainActivity=(MainActivity) getActivity();

                FragmentManager fm=mainActivity.getSupportFragmentManager();
                Fragment fragment=fm.findFragmentById(R.id.fragmentRight);
                View v=fragment.getView();
                TextView tv=v.findViewById(R.id.text);
                tv.setText("杨晨曦");
            }
        });
        Button btnmty=view.findViewById(R.id.mty);
        btnmty.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //首先找到MAINACTIVITY
                MainActivity mainActivity=(MainActivity) getActivity();

                FragmentManager fm=mainActivity.getSupportFragmentManager();
                Fragment fragment=fm.findFragmentById(R.id.fragmentRight);
                View v=fragment.getView();
                TextView tv=v.findViewById(R.id.text);
                tv.setText("马钿雨");
            }
        });
        Button btnzzy=view.findViewById(R.id.zzy);
        btnzzy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //首先找到MAINACTIVITY
                MainActivity mainActivity=(MainActivity) getActivity();

                FragmentManager fm=mainActivity.getSupportFragmentManager();
                Fragment fragment=fm.findFragmentById(R.id.fragmentRight);
                View v=fragment.getView();
                TextView tv=v.findViewById(R.id.text);
                tv.setText("曾致远");
            }
        });
        return view;
    }
}
